<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">
	

	<ui:composition template="/templates/common.xhtml">

		<ui:define name="pageTitle">Listagem de Pessoas</ui:define>

		<ui:define name="pageHeader">Listagem de Pessoas</ui:define>

		
		<ui:define name="body">
			<h:messages errorStyle="color: red" infoStyle="color: green" layout="table" />
            <h:form id="personListForm" styleClass="table_list">
                <h:commandButton action="#{personDetailController.newSetup}" value="Cadastrar Pessoa" />
	            <h:dataTable value="#{personController.personList}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="odd_row,even_row" rules="all" style="border:solid 1px">
	                        <h:column>
	                            <f:facet name="header">
	                                <h:outputText value="Id"/>
	                            </f:facet>
	                            <h:outputText value=" #{item.personId}"/>
	                        </h:column>
	                        <h:column>
	                            <f:facet name="header">
	                                <h:outputText value="Nome"/>
	                            </f:facet>
	                            <h:outputText value=" #{item.name}"/>
	                        </h:column>	                        
	                        <h:column>
	                        	<f:facet name="header">
	                                <h:outputText value="Nascimento"/>
	                            </f:facet>
	                        	<h:outputText value="#{item.birthDate}" >
              						<f:convertDateTime pattern="dd/MM/yyyy" />
 								</h:outputText>
	                        </h:column>
	                        <h:column>
	                        	<f:facet name="header">
	                                <h:outputText value="Nº Experiências"/>
	                            </f:facet>
	                        	<h:outputText value="#{ fn:length(item.personExperiences) }" />              						
	                        </h:column>
	                        <h:column>
	                        	<f:facet name="header">
	                                <h:outputText value="Ativo"/>
	                            </f:facet>
	                            <h:selectBooleanCheckbox value="#{item.active}" >
	                            	<f:ajax event="click" listener="#{personController.activeChange}" immediate="true"/>
	                            </h:selectBooleanCheckbox>
	                        </h:column>
	                        
	                        <h:column>
                            <f:facet name="header">
                                <h:outputText escape="false" value="Ação"/>
                            </f:facet>
                            <h:commandButton value="Consultar" action="#{personDetailController.detailSetup}" image="/images/show.png"/>
                            <h:outputText value=" "/>
                            <h:commandButton value="Editar" action="#{personDetailController.editSetup}" image="/images/edit.png"/>
                            <h:outputText value=" "/>
                            <h:commandButton value="Excluir" action="#{personController.delete}" image="/images/delete.png"/>
                        </h:column>
	                    </h:dataTable>
	        </h:form>
                    
		</ui:define>
	</ui:composition>
</html>